﻿using ZYCommon;
using System;
using System.Collections;
using System.Data;
using System.Drawing;
using System.IO;
using System.Runtime.CompilerServices;
using System.Windows.Forms;

namespace TextEditor
{
    

    public class ZYKBTreeView : TreeView
    {
        private bool bolDesignKBMode = false;
        private bool bolDoubleClickMode = false;
        private bool bolMatchAll = false;
        private bool bolShowKBItem = false;
        private bool bolShowNormalKBItem = false;
        private bool bolShowSystemKBItem = false;
        private bool bolShowTemplateKBItem = false;
        private bool bolStartMatch = false;
        public bool EnableClickEvent = false;
        private static ArrayList myAllKBTreeView = new ArrayList();
        private Control myBindControl;
        private TreeNode myDragNode = null;
        private ZYKBBuffer myKBBuffer = null;
        private TreeNode myLastDragNode = null;
        private Point myLastMousePos = Point.Empty;
        private KB_List myRootKBList = null;
        private TreeNode myStartNode = null;
        public EventHandler OnHandleCommand = null;
        public static bool RunInDesigner = false;
        private string strSearchText = null;

        public event KBItemClickHandler KBItemClick;

        public event KBListClickHandler KBListClick;

        public ZYKBTreeView()
        {
            base.Indent = 14;
            base.ItemHeight = 0x12;
            base.HideSelection = false;
            base.FullRowSelect = false;
            base.ImageList = GetKBImageList();
            myAllKBTreeView.Add(this);
        }

        private void Alert(string strAlert)
        {
            MessageBox.Show(this, strAlert, "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
        }

        private bool CanDrag(DragEventArgs drgevent)
        {
            bool flag = false;
            if (!this.DesignKBMode)
            {
                return false;
            }
            ArrayList data = drgevent.Data.GetData(typeof(ArrayList)) as ArrayList;
            if ((data != null) && (data.Count > 0))
            {
                Point p = new Point(drgevent.X, drgevent.Y);
                p = base.PointToClient(p);
                TreeNode nodeAt = base.GetNodeAt(p);
                if (nodeAt == null)
                {
                    return flag;
                }
                if (nodeAt == this.myLastDragNode)
                {
                    return true;
                }
                KB_List tag = nodeAt.Tag as KB_List;
                if (tag != null)
                {
                    if (((data[0] is KB_Item) && tag.EnableAddItem()) && ((data[0] as KB_Item).KBSEQ != tag.SEQ))
                    {
                        flag = true;
                    }
                    if (((data[0] is KB_List) && tag.EnableAddChild()) && ((data[0] as KB_List).ParentSEQ != tag.SEQ))
                    {
                        flag = true;
                    }
                }
                if (flag)
                {
                    if (this.myLastDragNode != null)
                    {
                        this.RefreshNode(this.myLastDragNode);
                    }
                    this.myLastDragNode = nodeAt;
                    nodeAt.BackColor = SystemColors.Highlight;
                    nodeAt.ForeColor = SystemColors.HighlightText;
                }
            }
            return flag;
        }

        protected override void Dispose(bool disposing)
        {
            myAllKBTreeView.Remove(this);
            if (disposing && (base.ImageList != null))
            {
                base.ImageList.Dispose();
            }
        }

        public static int GetICONIndex(ZYDBRecordBase myRecord, bool bolExpanded)
        {
            int num = 0;
            if (myRecord != null)
            {
                KB_List list = myRecord as KB_List;
                if (list != null)
                {
                    if (list.InputBoxAttribute)
                    {
                        num = 12;
                    }
                    else if (!RunInDesigner || StringCommon.isBlankString(list.ListSQL))
                    {
                        if (list.HasChildren())
                        {
                            if (bolExpanded)
                            {
                                num = 11;
                            }
                            else
                            {
                                num = 10;
                            }
                        }
                        else if (bolExpanded)
                        {
                            num = 1;
                        }
                        else
                        {
                            num = 2;
                        }
                    }
                    else
                    {
                        num = 13;
                    }
                }
                KB_Item item = myRecord as KB_Item;
                if (item != null)
                {
                    if (item.isCreated())
                    {
                        return 8;
                    }
                    if (item.isNormalItem())
                    {
                        return 3;
                    }
                    if (item.isSystemItem())
                    {
                        return 9;
                    }
                    if (item.isTemplate())
                    {
                        return 4;
                    }
                    if (item.isLink())
                    {
                        num = 14;
                    }
                }
            }
            return num;
        }

        public static Color GetItemBackColor(ZYDBRecordBase myRecord)
        {
            if (RunInDesigner && (myRecord != null))
            {
                if (myRecord.isNewRecord())
                {
                    return Color.Gold;
                }
                if (myRecord.isDeleted())
                {
                    return Color.Salmon;
                }
                if (myRecord.isModified())
                {
                    return Color.LightGreen;
                }
            }
            return Color.White;
        }

        public static ImageList GetKBImageList()
        {
            string[] strArray = new string[] { 
                "Qk02AwAAAAAAADYAAAAoAAAAEAAAABAAAAABABgAAAAAAAADAADEDgAAxA4AAAAAAAAAAAAA////hISE\r\n\t\t\t\tAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////////////////////////hISE////////////////\r\n\t\t\t\t////////////AISEAAAAAAAAAAAAAISE////////////hISE////////////////////////////AAAA\r\n\t\t\t\tAP//AP//AP//AAAA////////////hISE////////hISEhISEhISEhISE////AAAAAP//AP//AP//AAAA\r\n\t\t\t\t////////////hISE////////////////////////////AISEAAAAAAAAAAAAAISE////////////hISE\r\n\t\t\t\t////////hISEhISEhISEhISE////////AAAA////////////////////////hISE////////////////\r\n\t\t\t\t////////////AISEhISEhISEhISEhISE////////////hISE////////hISEhISEhISEhISE////AISE\r\n\t\t\t\tAP//AP//xsbGAAAA////////////hISE////////////////////hISEAAAAAISEAP//AP//AP//xsbG\r\n\t\t\t\tAAAA////////hISE////////////////////////////hAAAAAAAAP//AP//AP//xsbGAAAA////hISE\r\n\t\t\t\t////////////xsbGAAAAAAAAAAAAAISEhISEAAAAAP//AP//AP//AAAA////hISEhISEhISEhISEhISE\r\n\t\t\t\tAAAAAP//AP//xsbGhISEhISExsbGAP//AP//AAAA////////////////////////AISEAP//AP//AP//\r\n\t\t\t\tAISEAISEAP//AP//AP//AAAA////////////////////////////AISEAP//AP//AP//AP//AP//AP//\r\n\t\t\t\txsbGhISE////////////////////////////////AISEAP//AP//AP//AP//xsbGAISE////////////\r\n\t\t\t\t////////////////////////////AISEAISEAISEAISEAISE////////", "Qk02AwAA AAAAADYA AAAoAAAA EAAAABAA  AAABABgA AAAAAAAD AADEDgAA xA4AAAAA \r\n\t\t\t\tAAAAAAAA //////// //////// ////////  //////// ZmZmZmZm ZmZmZmZm ZmZmZmZm \r\n\t\t\t\tZmZm//// //////// //////// ////////  //////// ZmZm0Pb/ 0Pb/our/ c9n6Tdv/ \r\n\t\t\t\tZmZm//// //////// //////// ////////  //////// ZmZm0Pb/ 0Pb/our/ c9n6Tdv/ \r\n\t\t\t\tZmZm//// //////// //////// AAAAAAAA  AAAAAAAA ZmZm0Pb/ 0Pb/our/ c9n6Tdv/ \r\n\t\t\t\tZmZm//// //////// ////AAAA 6dzCZmZm  4M2o2MCS ZmZm0Pb/ 0Pb/our/ c9n6Tdv/ \r\n\t\t\t\tZmZm//// //////// AAAA7uPP ZmZmZmZm  ZmZm2MCS ZmZm0Pb/ 0Pb/our/ c9n6Tdv/ \r\n\t\t\t\tZmZm//// ////AAAA 9e7h7uPP ZmZmZmZm  ZmZmZmZm ZmZm0Pb/ 0Pb/our/ c9n6Tdv/ \r\n\t\t\t\tZmZm//// AAAA9/f3 9e7hZmZm gOb/ZmZm  ZmZm7OXf ZmZm0Pb/ 0Pb/our/ c9n6ZmZm \r\n\t\t\t\t//////// AAAA9/f3 ZmZm0Pb/ gOb/ZmZm  ZmZm//// ZmZmZmZm ZmZmZmZm ZmZm//// \r\n\t\t\t\t//////// AAAA9/f3 ZmZm0Pb/ gOb/ZmZm  ZmZm//// ////ZmZm 1Zl9s5hj AAAA//// \r\n\t\t\t\t//////// AAAA9/f3 ZmZm0Pb/ gOb/ZmZm  ZmZm//// ////ZmZm 1Zl9s5hj AAAA//// \r\n\t\t\t\t//////// AAAA9/f3 ZmZm0Pb/ gOb/ZmZm  ZmZm//// ////ZmZm AAAAAAAA AAAA//// \r\n\t\t\t\t//////// AAAA9/f3 ZmZm0Pb/ gOb/ZmZm  ZmZm//// ////ZmZm //////// //////// \r\n\t\t\t\t//////// AAAAAAAA ZmZm0Pb/ ZmZm////  ////ZmZm ZmZmZmZm //////// //////// \r\n\t\t\t\t//////// //////// ZmZmZmZm ////////  //////// //////// //////// //////// \r\n\t\t\t\t//////// //////// ZmZm//// ////////  //////// //////// //////// //////// \r\n\t\t\t\t////////", "Qk02AwAA AAAAADYA AAAoAAAA EAAAABAA  AAABABgA AAAAAAAD AADEDgAA xA4AAAAA \r\n\t\t\t\tAAAAAAAA //////// //////// ////AAAA  AAAA//// AAAA//// //////// //////// \r\n\t\t\t\t//////// //////// ////AAAA AAAA////  ////9/f3 8e3oAAAA //////// //////// \r\n\t\t\t\t//////// ////AAAA AAAA//// ////9/f3  5+fnzMzM vb291tbW AAAA//// //////// \r\n\t\t\t\t//////// AAAA//// ////9/f3 5+fnzMzM  sLCwAAAA hYWFsLCw 5+fnAAAA //////// \r\n\t\t\t\t//////// AAAA5+fn 3t7ezMzM sLCwAAAA  AAAA4M2o AAAAjY2N zMzM9/f3 AAAA//// \r\n\t\t\t\t//////// AAAAsLCw mZmZAAAA AAAA7uPP  6dzC5dS2 AAAAfHx8 mZmZ1tbW 9/f3AAAA \r\n\t\t\t\t//////// AAAAAAAA AAAA/fv4 9fLv9e7h  7uPP6dzC 5dS2AAAA fHx8mZmZ 1tbW9/f3 \r\n\t\t\t\tAAAA//// AAAA//// //////// 9/f39e7h  7uPP7uPP 5dS24M2o AAAAfHx8 mZmZ1tbW \r\n\t\t\t\tAAAA//// ////AAAA //////// ////9fLv  9e7h7uPP 6dzC5dS2 4M2oAAAA fHx8mZmZ \r\n\t\t\t\tAAAA9/f3 //////// AAAA//// /////fv4  9fLv7OXf 7uPP6dzC 4M2o4M2o AAAAAAAA \r\n\t\t\t\tAAAA5+fn //////// ////AAAA ////////  9/f39e7h 7uPP6dzC 5dS24M2o 2MCSAAAA \r\n\t\t\t\tsLCw5+fn //////// //////// AAAA////  ////9fLv 9e7h7uPP 6dzC5dS2 AAAAAAAA \r\n\t\t\t\t5+fn9/f3 //////// //////// ////AAAA  /////fv4 9e7h9e7h AAAAAAAA 5+fn9/f3 \r\n\t\t\t\t//////// //////// //////// ////////  AAAA//// AAAAAAAA 5+fn9/f3 //////// \r\n\t\t\t\t//////// //////// //////// ////////  ////AAAA 8e3o9/f3 //////// //////// \r\n\t\t\t\t//////// //////// //////// ////////  //////// //////// //////// //////// \r\n\t\t\t\t////////", " Qk04AwAA AAAAADYA AAAoAAAA EAAAABAA  AAABABgA AAAAAAAA AAASCwAA EgsAAAAA\r\n\t\t\t\tAAAAAAAA //////// //////// ////////  //////// //////// //////// ////////\r\n\t\t\t\t//////// //////// //////// ////////  //////// //////// //////// ////////\r\n\t\t\t\t//////// //////// Sli9TmLB V3vLY5XV  //////// //////// //////// ////////\r\n\t\t\t\t//////// //////// VXTIWHvK X4zSZ5/Z  rl4Y//// //////// //////// ////////\r\n\t\t\t\t//////// //////// YJDUYpXW Z5/anLoY  vpcYrl4Y //////// //////// ////////\r\n\t\t\t\t//////// //////// aqbca6jd qp0Ill4A  uocAuocA rl4Y//// //////// ////////\r\n\t\t\t\t//////// //////// ////MBYA cTwAcTwA  ll4AuocA uocAll4A //////// ////////\r\n\t\t\t\t//////// //////// //////// MBYA36kA  cTwAll4A uocAuocA rl4Y//// ////////\r\n\t\t\t\t//////// //////// //////// ////MBYA  36kAcTwA ll4AuocA uocAll4A ////////\r\n\t\t\t\t//////// //////// //////// ////////  MBYA36kA cTwAll4A uocAuocA rl4Y////\r\n\t\t\t\t//////// //////// //////// ////////  ////MBYA 36kAcTwA ll4AuocA uocAll4A\r\n\t\t\t\t//////// //////// //////// ////////  //////// MBYA36kA cTwAll4A uocA////\r\n\t\t\t\t//////// //////// //////// ////////  //////// ////MBYA 36kAcTwA ////////\r\n\t\t\t\t//////// //////// //////// ////////  //////// //////// MBYA//// ////////\r\n\t\t\t\t//////// //////// //////// ////////  //////// //////// //////// ////////\r\n\t\t\t\t//////// //////// //////// ////////  //////// //////// //////// ////////\r\n\t\t\t\t//////// AAA=", " Qk02AwAA AAAAADYA AAAoAAAA EAAAABAA  AAABABgA AAAAAAAD AAASCwAA EgsAAAAA\r\n\t\t\t\tAAAAAAAA //////// //////// ////////  //////// //////// //////// ////////\r\n\t\t\t\t//////// //////// //////// ////////  //////// //////// //////// ////////\r\n\t\t\t\t//////// //////// AAAAAAAA AAAAAAAA  AAAAAAAA AAAAAAAA AAAAAAAA ////////\r\n\t\t\t\t//////// //////// AAAA6t7H 59m+5NS1  4c+s3cqj 2sWb18CS 1LqJAAAA ZmZm////\r\n\t\t\t\t//////// //////// AAAA7ePP 6t7H59m+  5NS14c+s 3cqj2sWb 18CSAAAA ZmZmZmZm\r\n\t\t\t\t//////// //////// AAAA8ejY 7ePP6t7G  59m95NS1 4c+s3cqj 2sWbAAAA ZmZm////\r\n\t\t\t\t//////// //////// AAAA9O3h 8ejY7ePP  6t7G59m9 5NS14c+s 3cmjAAAA ////////\r\n\t\t\t\t//////// //////// AAAA9/Lp 9O3g8OjX  7ePP6t7G 59m95NS1 4M6rAAAA ////////\r\n\t\t\t\t//////// //////// AAAA+vfy 9/Lp9O3g  8OjX7ePP 6t7G59m9 49O0AAAA ////////\r\n\t\t\t\t//////// //////// AAAA/fz7 +vfx9/Lp  9O3g8OjX 7ePP6t3F 59i9AAAA ////////\r\n\t\t\t\t//////// //////// AAAA//// /fz6+vfx  9/Lp9O3g 8OjX7eLO 6t3FAAAA ////////\r\n\t\t\t\t//////// //////// AAAA//// /////fz6  +vfx9/Lp 8+3f8OjX AAAA//// ////////\r\n\t\t\t\t//////// //////// AAAA//// ////////  /fz6+vfx 9/LoAAAA //////// ////////\r\n\t\t\t\t//////// //////// AAAAAAAA AAAAAAAA  AAAAAAAA AAAA//// //////// ////////\r\n\t\t\t\t//////// //////// //////// ////////  //////// //////// //////// ////////\r\n\t\t\t\t//////// //////// //////// ////////  //////// //////// //////// ////////\r\n\t\t\t\t////////", "Qk0mBQAAAAAAADYEAAAoAAAAEAAAAA8AAAABAAgAAAAAAPAAAADEDgAAxA4AAAAAAAAAAAAAAAAAAAAA\r\n\t\t\t\tgAAAgAAAAICAAIAAAACAAIAAgIAAAMDAwADA3MAA8MikAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\r\n\t\t\t\tAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\r\n\t\t\t\tAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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AAAAAAAAAAA\r\n\t\t\t\tAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\r\n\t\t\t\tAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\r\n\t\t\t\tAAAAAAAAAAAAAAAAAAAAAAAA8Pv/AKSgoACAgIAAAAD/AAD/AAAA//8A/wAAAP8A/wD//wAA////AP//\r\n\t\t\t\t//////////////////////8AAAAAAAAAAAAAAP//////AP///////////wD//////wD///////////8A\r\n\t\t\t\t//////8A////////////AP//////AP///////////wD//////wD///////////8A//////8A////////\r\n\t\t\t\t////AP//////AP///////////wD//////wD///////////8A//////8A////////AAAAAP//////AP//\r\n\t\t\t\t/////wD/AP///////wD///////8AAP////////8AAAAAAAAAAP///////////////////////////w==", "Qk1+AAAAAAAAAD4AAAAoAAAAEAAAABAAAAABAAEAAAAAAEAAAADEDgAAxA4AAAAAAAAAAAAAAAAAAP//\r\n\t\t\t\t/wD//wAA//8AAP9/AAD/fwAA/n8AAPW/AAD7vwAA/78AAP/fAAD/3wAA/98AAP/vAAD/7wAA//8AAP//\r\n\t\t\t\tAAD//wAA", "Qk32AAAAAAAAAHYAAAAoAAAAEAAAABAAAAABAAQAAAAAAIAAAADEDgAAxA4AAAAAAAAAAAAAAAAAAAAA\r\n\t\t\t\tgAAAgAAAAICAAIAAAACAAIAAgIAAAICAgADAwMAAAAD/AAD/AAAA//8A/wAAAP8A/wD//wAA////AP//\r\n\t\t\t\t////////////////////+f//////n/+Zn////////5mZ////+f//+Zn///+f////mZ//+Z/////5mf+Z\r\n\t\t\t\t//////+ZmZ////////mZ////////mZmf//////mZ/5n////5mZ//+Z///5mZ////mf//mZ//////n///\r\n\t\t\t\t////////", "Qk02AwAAAAAAADYAAAAoAAAAEAAAABAAAAABABgAAAAAAAADAADEDgAAxA4AAAAAAAAAAAAA////////\r\n\t\t\t\t////////////////////////////////////////////////////////////////////////////////\r\n\t\t\t\t////////////////////////////////////////////////////////////////////////////////\r\n\t\t\t\t////////////////////////////////////////AAAAAAAA////////////////////////////////\r\n\t\t\t\t////////////////////////AAAAAP//AAAA////////////////////////////////////////////\r\n\t\t\t\t////////////AAAAAP//AAAA////////////////////////////////////////////////////AAAA\r\n\t\t\t\tAP//AP//AAAA////////////////////////////////////////////////////AAAAAP//AP//AAAA\r\n\t\t\t\t////////////////////////////////////////////gICAAAAAAAAAAP//AP//AAAA////////////\r\n\t\t\t\t////////////////////////////AAAAAP//AP//AP//AAAAAAAA////////////////////////////\r\n\t\t\t\t////////////////AAAAAP//AP//AAAA////////////////////////////////////////////////\r\n\t\t\t\tAAAAAP//AP//AP//AAAA////////////////////////////////////////////////AAAAAP//AP//\r\n\t\t\t\tAP//AAAA////////////////////////////////////////////AAAAAAAAAAAAAAAAAAAA////////\r\n\t\t\t\t////////////////////////////////////////////////////////////////////////////////\r\n\t\t\t\t////////////////////////////////////////////////////////", "Qk02AwAAAAAAADYAAAAoAAAAEAAAABAAAAABABgAAAAAAAADAADEDgAAxA4AAAAAAAAAAAAA////////\r\n\t\t\t\t////////////////////////////////////////////////////////////////////////////////\r\n\t\t\t\t////AAAAAAAAAAAA////////////////////////////////////AAAAAAAA////////AAAAAP//AAAA\r\n\t\t\t\t////////AAAAAAAA////////////////AISEAP//AAAAAISEAAAAAISEAISEAAAAAAAAAAAAAISEAISE\r\n\t\t\t\tAAAA////////////AISEAP//AAAAAISEAISEAISE////AAAAAP//AISEAISEAISEAAAA////////AAAA\r\n\t\t\t\tAAAAAP//AP//AAAAAISEAISExsbGAISEAAAAAISE////xsbGAAAAAAAAAAAAAISEAISEAAAAAISE////\r\n\t\t\t\t////AP//AP//////AP//AP//AISEAAAAAISEAISEAAAAAISEAISEAISE////AP//AAAAAAAAAAAAAAAA\r\n\t\t\t\tAAAAxsbGAP//AAAAAISEAISEAISE////AISE////AP//hISEhISE////hISEhISEAAAAAISE////AP//\r\n\t\t\t\t////AP//AISEAISEAISEAISE////hISEhISE////xsbGhISEAAAAhISEAP//xsbGAAAAAAAA////////\r\n\t\t\t\tAAAAAISE////////hISE////hISEhISEAAAA////AP//AISEAAAA////////////AISE////AP//AISE\r\n\t\t\t\thISE////xsbGhISEAAAAAISE////AP//AAAA////////////////AISEAISE////hISExsbGhISEhISE\r\n\t\t\t\tAAAA////AISEhISE////////////////////////////////hISE////////xsbGAAAA////////////\r\n\t\t\t\t////////////////////////////////////hISEhISEhISE////////////////////////////////\r\n\t\t\t\t////////////////////////////////////////////////////////", "Qk02AwAA AAAAADYA AAAoAAAA EAAAABAA  AAABABgA AAAAAAAD AADEDgAA xA4AAAAA \r\n\t\t\t\tAAAAAAAA //////// //////// ////////  //////// //////// //////// AAAA//// \r\n\t\t\t\t//////// //////// //////// ////////  //////// //////// AAAAAAAA AAAAZmZm \r\n\t\t\t\t//////// //////// //////// ////////  //////// AAAAAAAA mng44NbD AAAAZmZm \r\n\t\t\t\tZmZm//// //////// //////// ////////  AAAAAAAA pIlVpIlV pIlV4NbD AAAAZmZm \r\n\t\t\t\t//////// //////// //////// AAAAAAAA  rZdurZdu rZdupIlV pIlV4NbD AAAA//// \r\n\t\t\t\t//////// //////// AAAAAAAA u6ONu6ON  tpyFrZdu rZdurZdu 2MCS7OXf AAAA//// \r\n\t\t\t\t//////// ////AAAA zrWtvK6W vK6WvK6W  u6ONtpyF 4M2o4M2o 2MCS9e7h AAAA//// \r\n\t\t\t\t//////// ////AAAA 9e7h9e7h 7uPPvK6W  6dzC6dzC 5dS24M2o 4M2o9e7h AAAA//// \r\n\t\t\t\t//////// ////AAAA 9fLv9e7h 9e7h7uPP  7uPP6dzC 6dzC5dS2 5dS29e7h AAAA//// \r\n\t\t\t\t//////// ////AAAA /fv49fLv 9fLv9e7h  9e7h7uPP 7uPP6dzC 5dS29e7h AAAA//// \r\n\t\t\t\t//////// ////AAAA /////fv4 9fLv9fLv  9e7h9e7h 7uPP//// ////6dzC AAAA//// \r\n\t\t\t\t//////// ////AAAA //////// ////9/f3  9/f3//// ////7uPP xoQAxoQA AAAA//// \r\n\t\t\t\t//////// ////AAAA //////// ////////  ////9fLv AAAAAAAA xoQAAAAA //////// \r\n\t\t\t\t//////// ////AAAA //////// ////////  AAAAAAAA //////// AAAAAAAA //////// \r\n\t\t\t\t//////// ////AAAA //////// AAAAAAAA  //////// //////// //////// //////// \r\n\t\t\t\t//////// ////AAAA AAAAAAAA ////////  //////// //////// //////// //////// \r\n\t\t\t\t////////", "Qk02AwAA AAAAADYA AAAoAAAA EAAAABAA  AAABABgA AAAAAAAD AADEDgAA xA4AAAAA \r\n\t\t\t\tAAAAAAAA //////// //////// ////////  //////// //////// //////// ////AAAA \r\n\t\t\t\t//////// //////// //////// ////////  //////// //////// ////AAAA AAAAAAAA \r\n\t\t\t\tZmZm//// //////// //////// ////////  //////// ////AAAA AAAAAAAA AAAAAAAA \r\n\t\t\t\tZmZmZmZm //////// //////// ////////  ////AAAA AAAAAAAA 2MCS2MCS AAAAAAAA \r\n\t\t\t\tZmZm//// //////// //////// ////AAAA  AAAAAAAA 8Mqm8Mqm 2MCSAAAA pIlVAAAA \r\n\t\t\t\t//////// //////// ////AAAA AAAAAAAA  6dzC6dzC 8Mqm8Mqm 8MqmAAAA 2MCSAAAA \r\n\t\t\t\t//////// //////// AAAAAAAA 7uPP7uPP  7uPP6dzC 6dzC8Mqm AAAA9e7h 2MCSAAAA \r\n\t\t\t\t//////// //////// AAAA9e7h 9e7h9e7h  7uPP7uPP 6dzC6dzC AAAA9e7h 2MCSAAAA \r\n\t\t\t\t//////// ////AAAA /fv4/fv4 9e7h9e7h  9e7h7uPP AAAAAAAA 5dS29e7h 4M2oAAAA \r\n\t\t\t\t//////// ////AAAA /////fv4 /fv49e7h  AAAAAAAA 7uPP7uPP //////// 5dS2AAAA \r\n\t\t\t\t//////// AAAA//// //////// AAAAAAAA  9fLv9e7h //////// 7uPP6dzC xoQAAAAA \r\n\t\t\t\t//////// AAAA//// AAAAAAAA ////////  //////// 9e7h9e7h xoQAxoQA xoQAAAAA \r\n\t\t\t\t//////// AAAAAAAA AAAA//// ////////  /////fv4 9fLvAAAA xoQAxoQA xoQAAAAA \r\n\t\t\t\t//////// //////// AAAA//// ////////  ////AAAA AAAA//// AAAAAAAA AAAA//// \r\n\t\t\t\t//////// //////// AAAA//// ////AAAA  AAAA//// //////// //////// //////// \r\n\t\t\t\t//////// //////// AAAAAAAA AAAA////  //////// //////// //////// //////// \r\n\t\t\t\t////////", "Qk32AAAAAAAAAHYAAAAoAAAAEAAAABAAAAABAAQAAAAAAIAAAADEDgAAxA4AAAAAAAAAAAAA////AAAA\r\n\t\t\t\tAACAgIAAwMDAAP///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\r\n\t\t\t\tAAAAAAAAAAAAAAAAAAADMzMzMzMzMAMAAAAAAAAwAwAREBEQADADAQAQEAEAMAMAERAQAQAwAwEAEBAB\r\n\t\t\t\tADADABEAERAAMAMAAAAQAAAwAwAAABAAADADAAAAAAAAMAMAAAAAAAAwAzMzMzMzMzAAAAAAAAAAAAAA\r\n\t\t\t\tAAAAAAAA", "Qk02AwAAAAAAADYAAAAoAAAAEAAAABAAAAABABgAAAAAAAADAADEDgAAxA4AAAAAAAAAAAAA////////\r\n\t\t\t\t////////////////////////////////////////////////////////////////////////////////\r\n\t\t\t\t////////////////////////////////////////////////////////////////////////////////\r\n\t\t\t\t////////////////////////////////////////////////////////jz0Ajz0A////////////////\r\n\t\t\t\t////////////jz0Ajz0A////////////jz0Ajz0Ajz0A////////////jz0Ajz0Ajz0Ajz0Ajz0A////\r\n\t\t\t\tjz0Ajz0A////jz0Ajz0A////jz0Ajz0A////////jz0Ajz0A////////////////jz0Ajz0A////jz0A\r\n\t\t\t\tjz0A////jz0Ajz0A////////jz0Ajz0A////////////jz0Ajz0Ajz0A////jz0Ajz0A////jz0Ajz0A\r\n\t\t\t\t////////jz0Ajz0A////////jz0Ajz0Ajz0A////////jz0Ajz0A////jz0Ajz0A////////jz0Ajz0A\r\n\t\t\t\t////////jz0Ajz0A////////////jz0Ajz0A////jz0Ajz0A////////jz0Ajz0A////////jz0Ajz0A\r\n\t\t\t\t////jz0A////jz0Ajz0A////jz0Ajz0A////////jz0Ajz0A////////////jz0Ajz0A////////////\r\n\t\t\t\tjz0Ajz0Ajz0A////////////jz0Ajz0A////////////////////////////////////////////////\r\n\t\t\t\t////////////////////////////////////////////////////////////////////////////////\r\n\t\t\t\t////////////////////////////////////////////////////////////////////////////////\r\n\t\t\t\t////////////////////////////////////////////////////////", "Qk02BQAAAAAAADYEAAAoAAAAEAAAABAAAAABAAgAAAAAAAABAADEDgAAxA4AAAAAAAAAAAAAAAAAAAAA\r\n\t\t\t\tgAAAgAAAAICAAIAAAACAAIAAgIAAAMDAwADA3MAA8MqmAAAgQAAAIGAAACCAAAAgoAAAIMAAACDgAABA\r\n\t\t\t\tAAAAQCAAAEBAAABAYAAAQIAAAECgAABAwAAAQOAAAGAAAABgIAAAYEAAAGBgAABggAAAYKAAAGDAAABg\r\n\t\t\t\t4AAAgAAAAIAgAACAQAAAgGAAAICAAACAoAAAgMAAAIDgAACgAAAAoCAAAKBAAACgYAAAoIAAAKCgAACg\r\n\t\t\t\twAAAoOAAAMAAAADAIAAAwEAAAMBgAADAgAAAwKAAAMDAAADA4AAA4AAAAOAgAADgQAAA4GAAAOCAAADg\r\n\t\t\t\toAAA4MAAAODgAEAAAABAACAAQABAAEAAYABAAIAAQACgAEAAwABAAOAAQCAAAEAgIABAIEAAQCBgAEAg\r\n\t\t\t\tgABAIKAAQCDAAEAg4ABAQAAAQEAgAEBAQABAQGAAQECAAEBAoABAQMAAQEDgAEBgAABAYCAAQGBAAEBg\r\n\t\t\t\tYABAYIAAQGCgAEBgwABAYOAAQIAAAECAIABAgEAAQIBgAECAgABAgKAAQIDAAECA4ABAoAAAQKAgAECg\r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tBKT/////pPz8/PwCAgICBvwA/////6T8/AgCAgICAvz8AP////+k/AgCAgICBAYEAgD/////pPwHCAgE\r\n\t\t\t\tAgL8AgIA/////6Sk/P8H/Pz8/AICpP//////pP8H/wgCAgICAP////////+kpAYHCAgCAP//////////\r\n\t\t\t\t/6SkpKSkpP////////8=", "Qk02BQAA AAAAADYE AAAoAAAA EAAAABAA  AAABAAgA AAAAAAAB AADEDgAA xA4AAAAA\r\n\t\t\t\tAAAAAAAA AAAAAP// /wAA//8A gICAAP//  /wAAAAAA AAAAAAAA AAAAAAAA AAAAAAAA\r\n\t\t\t\tAAAAAAAA AAAAAAAA AAAAAAAA AAAAAAAA  AAAAAAAA AAAAAAAA AAAAAAAA AAAAAAAA\r\n\t\t\t\tAAAAAAAA AAAAAAAA AAAAAAAA AAAAAAAA  AAAAAAAA AAAAAAAA AAAAAAAA AAAAAAAA\r\n\t\t\t\tAAAAAAAA AAAAAAAA AAAAAAAA AAAAAAAA  AAAAAAAA AAAAAAAA AAAAAAAA AAAAAAAA\r\n\t\t\t\tAAAAAAAA AAAAAAAA AAAAAAAA AAAAAAAA  AAAAAAAA AAAAAAAA AAAAAAAA AAAAAAAA\r\n\t\t\t\tAAAAAAAA AAAAAAAA AAAAAAAA AAAAAAAA  AAAAAAAA AAAAAAAA AAAAAAAA AAAAAAAA\r\n\t\t\t\tAAAAAAAA AAAAAAAA AAAAAAAA AAAAAAAA  AAAAAAAA AAAAAAAA AAAAAAAA AAAAAAAA\r\n\t\t\t\tAAAAAAAA AAAAAAAA AAAAAAAA AAAAAAAA  AAAAAAAA AAAAAAAA AAAAAAAA AAAAAAAA\r\n\t\t\t\tAAAAAAAA AAAAAAAA AAAAAAAA AAAAAAAA  AAAAAAAA AAAAAAAA AAAAAAAA AAAAAAAA\r\n\t\t\t\tAAAAAAAA AAAAAAAA AAAAAAAA AAAAAAAA  AAAAAAAA AAAAAAAA AAAAAAAA AAAAAAAA\r\n\t\t\t\tAAAAAAAA AAAAAAAA AAA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AAgEA AQEBAQAB AgEAAQIB\r\n\t\t\t\tAgECAAEB AQEAAgEC AQIBAgEC AQABAQEB  AAECAQIB AgMAAwIA AQEBAQAC AQIBAgEA\r\n\t\t\t\tAQABAAEB AQEAAQIB AgECAwAD AgABAQEB  AAIBAgEC AQIBAgEA AQEBAQAA AAAAAAAA\r\n\t\t\t\tAAAAAAEB AQEBAQEB AQEBAQEB AQEBAQEB  AQEBAQEB AQEBAQEB AQE=", 
                "Qk02AwAA AAAAADYA AAAoAAAA EAAAABAA  AAABABgA AAAAAAAD AADEDgAA xA4AAAAA\r\n\t\t\t\tAAAAAAAA ////gICA gICAgICA gICAgICA  gICAgICA gICAgICA gICAgICA gICAgICA\r\n\t\t\t\tgICAgICA AAAAAAAA AAAAAAAA AAAAAAAA  AAAAAAAA AAAAAAAA AAAAAAAA AAAAAAAA\r\n\t\t\t\tAAAAgICA AAAA//// //////// ////////  //////// //////// //////// ////////\r\n\t\t\t\tAAAAgICA AAAA//// AAAAAAAA AAAAAAAA  AAAAAAAA AAAAAAAA AAAAAAAA AAAA////\r\n\t\t\t\tAAAAgICA AAAA//// //////// ////////  //////// //////// //////// ////////\r\n\t\t\t\tAAAAgICA AAAA//// AAAAAAAA AAAAAAAA  AAAAAAAA AAAAAAAA AAAAAAAA AAAA////\r\n\t\t\t\tAAAAgICA AAAA//// //////// ////////  //////// //////// //////// ////////\r\n\t\t\t\tAAAAgICA AAAA//// AAAAAAAA AAAAAAAA  AAAAAAAA AAAAAAAA AAAAAAAA AAAA////\r\n\t\t\t\tAAAAgICA AAAA//// //////// ////////  //////// //////// //////// ////////\r\n\t\t\t\tAAAAgICA AAAA//// AAAAAAAA AAAA////  AAAAAAAA AAAA//// AAAAAAAA AAAA////\r\n\t\t\t\tAAAAgICA AAAA//// ////AAAA wMDA////  wMDAAAAA //////// //////// ////////\r\n\t\t\t\tAAAAgICA AAAA//// ////wMDA AAAAAAAA  AAAAwMDA //////// AAAAAAAA AAAA////\r\n\t\t\t\tAAAAgICA AAAA//// //////// gICAgICA  gICA//// //////// //////// ////////\r\n\t\t\t\tAAAAgICA AAAA//// //////// ////AAAA  //////// //////// AAAAAAAA AAAA////\r\n\t\t\t\tAAAAgICA AAAA//// //////// ////////  //////// //////// //////// ////////\r\n\t\t\t\tAAAAgICA AAAAAAAA AAAAAAAA AAAAAAAA  AAAAAAAA AAAAAAAA AAAAAAAA AAAAAAAA\r\n\t\t\t\tAAAA////", " Qk02BQAA AAAAADYE AAAoAAAA EAAAABAA  AAABAAgA AAAAAAAB AADEDgAA xA4AAAAA\r\n\t\t\t\tAAAAAAAA gICAAIAA AAAAAP8A AAAAAP//  /wAAAAAA AAAAAAAA AAAAAAAA AAAAAAAA\r\n\t\t\t\tAAAAAAAA AAAAAAAA AAAAAAAA AAAAAAAA  AAAAAAAA AAAAAAAA AAAAAAAA AAAAAAAA\r\n\t\t\t\tAAAAAAAA AAAAAAAA AAAAAAAA AAAAAAAA  AAAAAAAA AAAAAAAA AAAAAAAA AAAAAAAA\r\n\t\t\t\tAAAAAAAA AAAAAAAA AAAAAAAA AAAAAAAA  AAAAAAAA AAAAAAAA AAAAAAAA AAAAAAAA\r\n\t\t\t\tAAAAAAAA AAAAAAAA AAAAAAAA AAAAAAAA  AAAAAAAA AAAAAAAA AAAAAAAA AAAAAAAA\r\n\t\t\t\tAAAAAAAA AAAAAAAA AAAAAAAA AAAAAAAA  AAAAAAAA AAAAAAAA AAAAAAAA AAAAAAAA\r\n\t\t\t\tAAAAAAAA AAAAAAAA AAAAAAAA AAAAAAAA  AAAAAAAA AAAAAAAA AAAAAAAA AAAAAAAA\r\n\t\t\t\tAAAAAAAA AAAAAAAA AAAAAAAA AAAAAAAA  AAAAAAAA AAAAAAAA AAAAAAAA AAAAAAAA\r\n\t\t\t\tAAAAAAAA AAAAAAAA AAAAAAAA AAAAAAAA  AAAAAAAA AAAAAAAA AAAAAAAA AAAAAAAA\r\n\t\t\t\tAAAAAAAA AAAAAAAA AAAAAAAA AAAAAAAA  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D AwMDBAQE\r\n\t\t\t\tAQQBBAQE BAQEBAQE BAQAAQEE AQQEBAQE  BAQEBAQE AQEBBAEE BAQEAwMD AwMDBAEB\r\n\t\t\t\tAQQBBAQE BAQEBAQE BAQAAQEB AQEEBAQE  BAQEBAQE BAQEBAQE BAQEAwMD AwMDAwMD\r\n\t\t\t\tAwMDAwQE BAQEBAQE BAQEBAQE BAQEBAQE  BAQEBAQE BAQEBAQE BAQEBAQE BAMDAwMD\r\n\t\t\t\tAwMDAwQE BAQEBAQE BAQEBAQE BAQEBAQE  BAQEBAQE BAQEBAQE BAQ=", "Qk02BQAA AAAAADYE AAAoAAAA EAAAABAA  AAABAAgA AAAAAAAB AADEDgAA xA4AAAAA\r\n\t\t\t\tAAAAAAAA AAAAAAAA gAAAgAAA AICAAIAA  AACAAIAA gIAAAICA gADAwMAA AAD/AAD/\r\n\t\t\t\tAAAA//8A /wAAAP8A /wD//wAA ////AAAA  AAAAAAAA AAAAAAAA AAAAAAAA AAAAAAAA\r\n\t\t\t\tAAAAAAAA AAAAAAAA AAAAAAAA AAAAAAAA  AAAAAAAA AAAAAAAA AAAAAAAA AAAAAAAA\r\n\t\t\t\tAAAAAAAA AAAAAAAA AAAAAAAA AAAAAAAA  AAAAAAAA AAAAAAAA AAAAAAAA AAAAAAAA\r\n\t\t\t\tAAAAAAAA AAAAAAAA AAAAAAAA AAAAAAAA  AAAAAAAA AAAAAAAA AAAAAAAA AAAAAAAA\r\n\t\t\t\tAAAAAAAA AAAAAAAA AAAAAAAA AAAAAAAA  AAAAAAAA AAAAAAAA AAAAAAAA AAAAAAAA\r\n\t\t\t\tAAAAAAAA AAAAAAAA AAAAAAAA AAAAAAAA  AAAAAAAA AAAAAAAA AAAAAAAA AAAAAAAA\r\n\t\t\t\tAAAAAAAA AAAAAAAA AAAAAAAA AAAAAAAA  AAAAAAAA AAAAAAAA AAAAAAAA AAAAAAAA\r\n\t\t\t\tAAAAAAAA AAAAAAAA AAAAAAAA AAAAAAAA  AA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AA AAAAAAAA\r\n\t\t\t\tAAAAAAAP AA8PDw8P Dw8PDw8P Dw8ADwAP  AA8ADwAP AA8ADwAP AA8AAAAA AAAAAAAA\r\n\t\t\t\tAAAAAAAP DwAODg4O Dg4ODgAP Dw8PDw8A  DgAAAAAO DgAPDw8P Dw8PAA4A DwAODgAA\r\n\t\t\t\tDw8PDw8P DwAOAAAO DgAPAAAP Dw8PDw8A  DgAODgAP DwAAAA8P Dw8PAA4O DgAPDw8A\r\n\t\t\t\tCwcADw8P DwAODgAP Dw8PAAsI AA8PDw8A  DgAPDw8P Dw8ACwcA Dw8PAAAP Dw8PDw8P\r\n\t\t\t\tAAsAAA8P DwAPDw8P Dw8PDw8A AQEADw8P  Dw8PDw8P Dw8PAAAA Dw8=", "Qk32AAAA AAAAAHYA AAAoAAAA EAAAABAA  AAABAAQA AAAAAIAA AADEDgAA xA4AAAAA\r\n\t\t\t\tAAAAAAAA AAAAAAAA gAAAgAAA AICAAIAA  AACAAIAA gIAAAICA gADAwMAA AAD/AAD/\r\n\t\t\t\tAAAA//8A /wAAAP8A /wD//wAA ////AP//  //////// //////// //////// ////////\r\n\t\t\t\t//////// //////// //////// ////////  //////// /wAAAAAA AP//AAAA AAAA////\r\n\t\t\t\t//////// //////// //////// ////////  //////// //////// //////// ////////\r\n\t\t\t\t////////",
                "Qk02AwAAAAAAADYAAAAoAAAAEAAAABAAAAABABgAAAAAAAAAAADEDgAAxA4AAAAAAAAAAAAA0Ztx0Ztx06B548St4MGqz6OGv4lotnxYtnxYvolpz6KC38Cp48aw1KJ70Ztx0Ztx1KB416iD5cax1KqNvopp0a6X7t7T+PLu+fPv7+HX1LGbv4tq06iK5Mm04Lyh16iE2aaB48St06aHxZNy7dfI9uri+PHr+vTv+vTw+fHr9evk7tnLxZV20KCB48Or7NLA4buf2LCUxJJx6Mq08d3O8+Ta8+bd9Ojg9Ojh8+ff8+Xb8d3O6sy4x5V01qqK4LeZ4cCmxpZ13LCS5siy7dbG7dfI4sWx58y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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
             };
            ImageList list = new ImageList();
            list.ImageSize = new Size(0x10, 0x10);
            list.TransparentColor = Color.White;
            foreach (string str in strArray)
            {
                MemoryStream stream = new MemoryStream(Convert.FromBase64String(str));
                Image image = Image.FromStream(stream);
                list.Images.Add(image);
            }
            return list;
        }

        public TreeNode GetNodeByKBList(KB_List myList, TreeNodeCollection myNodes)
        {
            if (myList != null)
            {
                if (myNodes == null)
                {
                    myNodes = base.Nodes;
                }
                foreach (TreeNode node in myNodes)
                {
                    if (node.Tag == myList)
                    {
                        return node;
                    }
                    TreeNode nodeByKBList = this.GetNodeByKBList(myList, node.Nodes);
                    if (nodeByKBList != null)
                    {
                        return nodeByKBList;
                    }
                }
            }
            return null;
        }

        public static void GlobalRefreshChileNode(ZYKBTreeView Sender, KB_List myList)
        {
            foreach (ZYKBTreeView view in myAllKBTreeView)
            {
                if ((view != Sender) || !view.IsDisposed)
                {
                    TreeNode nodeByKBList = view.GetNodeByKBList(myList, null);
                    if (nodeByKBList != null)
                    {
                        view.RefreshChildNode(nodeByKBList, true);
                    }
                }
            }
        }

        private TreeNode InnerSearchNode(TreeNodeCollection myNodes)
        {
            foreach (TreeNode node in myNodes)
            {
                if (this.bolStartMatch)
                {
                    if ((node.Text == this.strSearchText) || (!this.bolMatchAll && (node.Text.IndexOf(this.strSearchText) >= 0)))
                    {
                        return node;
                    }
                }
                else if (node == this.myStartNode)
                {
                    this.bolStartMatch = true;
                }
                TreeNode node2 = this.InnerSearchNode(node.Nodes);
                if (node2 != null)
                {
                    return node2;
                }
            }
            return null;
        }

        public KB_List InsertKBList()
        {
            KB_List selectedKBList = this.SelectedKBList;
            if ((selectedKBList != null) && (selectedKBList.Parent != null))
            {
                //string strData = dlgInputBox.InputBox("输入新的知识点的名称", "插入知识点", "");
                //if (!StringCommon.isBlankString(strData))
                //{
                //    KB_List list3 = selectedKBList.Parent.NewChildList(strData);
                //    if (list3 != null)
                //    {
                //        TreeNode myNode = new TreeNode();
                //        myNode.Tag = list3;
                //        this.RefreshNode(myNode);
                //        base.SelectedNode.Parent.Nodes.Add(myNode);
                //        myNode.EnsureVisible();
                //        base.SelectedNode = myNode;
                //        return list3;
                //    }
                //}
            }
            return null;
        }

        public void MoveNodeDown()
        {
            this.MoveTreeNode(false);
        }

        public void MoveNodeUp()
        {
            this.MoveTreeNode(true);
        }

        private void MoveTreeNode(bool bolUp)
        {
            if (((base.SelectedNode != null) && (base.SelectedNode.Tag is KB_List)) && (((base.SelectedNode.PrevNode != null) && bolUp) || ((base.SelectedNode.NextNode != null) && !bolUp)))
            {
                TreeNode parent = base.SelectedNode.Parent;
                TreeNode selectedNode = base.SelectedNode;
                TreeNode myNode = bolUp ? selectedNode.PrevNode : selectedNode.NextNode;
                KB_List tag = selectedNode.Tag as KB_List;
                KB_List list2 = myNode.Tag as KB_List;
                int listIndex = tag.ListIndex;
                tag.ListIndex = list2.ListIndex;
                list2.ListIndex = listIndex;
                selectedNode.Remove();
                parent.Nodes.Insert(bolUp ? myNode.Index : (myNode.Index + 1), selectedNode);
                selectedNode.EnsureVisible();
                base.SelectedNode = selectedNode;
                this.RefreshNode(selectedNode);
                this.RefreshNode(myNode);
            }
        }

        public bool NewFormItem()
        {
            return (this.NewKBItemWithStyle(100) != null);
        }

        public bool NewKBItem()
        {
            return (this.NewKBItemWithStyle(0) != null);
        }

        private KB_Item NewKBItemWithStyle(int Style)
        {
            KB_List selectedKBList = this.SelectedKBList;
            if ((selectedKBList != null) && !selectedKBList.HasChildren())
            {
                //string strData = dlgInputBox.InputBox("输入新增的项目文本", "新增项目", "");
                //if (!StringCommon.isBlankString(strData))
                //{
                //    KB_Item item = selectedKBList.NewItem(strData);
                //    if (item != null)
                //    {
                //        item.ItemStyle = Style;
                //        TreeNode myNode = new TreeNode();
                //        myNode.Tag = item;
                //        this.RefreshNode(myNode);
                //        base.SelectedNode.Nodes.Add(myNode);
                //        this.RefreshNode(base.SelectedNode);
                //        myNode.EnsureVisible();
                //        base.SelectedNode = myNode;
                //        return item;
                //    }
                //}
            }
            return null;
        }

        public KB_List NewKBList(int intKBStyle)
        {
            KB_List selectedKBList = this.SelectedKBList;
            if ((selectedKBList != null) && !selectedKBList.HasItems())
            {
                //string strData = dlgInputBox.InputBox("输入新的知识点的名称", "新增知识点", "");
                //if (!StringCommon.isBlankString(strData))
                //{
                //    KB_List list2 = selectedKBList.NewChildList(strData);
                //    if (list2 != null)
                //    {
                //        list2.KBStyle = intKBStyle;
                //        TreeNode myNode = new TreeNode();
                //        myNode.Tag = list2;
                //        this.RefreshNode(myNode);
                //        base.SelectedNode.Nodes.Add(myNode);
                //        this.RefreshNode(base.SelectedNode);
                //        myNode.EnsureVisible();
                //        base.SelectedNode = myNode;
                //        return list2;
                //    }
                //}
            }
            return null;
        }

        protected override void OnAfterCollapse(TreeViewEventArgs e)
        {
            this.SetTreeNodeICON(e.Node);
        }

        protected override void OnAfterExpand(TreeViewEventArgs e)
        {
            this.SetTreeNodeICON(e.Node);
        }

        protected override void OnAfterLabelEdit(NodeLabelEditEventArgs e)
        {
            if (e.Label != null)
            {
                KB_List tag = e.Node.Tag as KB_List;
                if (tag != null)
                {
                    if (!KB_List.CheckName(e.Label))
                    {
                        this.Alert("知识点名称不合法,不得为空且长度不得超过50个字符");
                    }
                    tag.Name = e.Label.Trim();
                    this.SetTreeNodeICON(e.Node);
                }
                KB_Item item = e.Node.Tag as KB_Item;
                if (item != null)
                {
                    if (!KB_Item.CheckItemText(e.Label))
                    {
                        this.Alert("列表项目文本不合法，不得为空且长度不得超过100个字符");
                    }
                    item.ItemText = e.Label;
                    this.SetTreeNodeICON(e.Node);
                }
            }
        }

        protected override void OnAfterSelect(TreeViewEventArgs e)
        {
            if (this.bolDoubleClickMode)
            {
                base.OnAfterSelect(e);
            }
            else
            {
                TreeNode treeNode = e.Node;
                if (treeNode != null)
                {
                    base.SelectedNode = treeNode;
                    KB_List tag = treeNode.Tag as KB_List;
                    if ((tag != null) && this.EnableClickEvent)
                    {
                        this.OnKBListClick(treeNode, tag);
                    }
                    KB_Item selectedItem = treeNode.Tag as KB_Item;
                    if ((selectedItem != null) && this.EnableClickEvent)
                    {
                        this.OnKBItemClick(treeNode, selectedItem);
                    }
                }
            }
        }

        protected override void OnBeforeLabelEdit(NodeLabelEditEventArgs e)
        {
            ZYDBRecordBase tag = e.Node.Tag as ZYDBRecordBase;
            if (((tag != null) && tag.isDeleted()) || (e.Node == base.Nodes[0]))
            {
                e.CancelEdit = true;
            }
        }

        protected override void OnDoubleClick(EventArgs e)
        {
            if (this.bolDoubleClickMode && (base.SelectedNode != null))
            {
                Point pt = base.PointToClient(Control.MousePosition);
                TreeNode selectedNode = base.SelectedNode;
                if (selectedNode.Bounds.Contains(pt))
                {
                    KB_List tag = selectedNode.Tag as KB_List;
                    if ((tag != null) && this.EnableClickEvent)
                    {
                        this.OnKBListClick(selectedNode, tag);
                    }
                    KB_Item selectedItem = selectedNode.Tag as KB_Item;
                    if ((selectedItem != null) && this.EnableClickEvent)
                    {
                        this.OnKBItemClick(selectedNode, selectedItem);
                    }
                }
            }
            else
            {
                base.OnDoubleClick(e);
            }
        }

        protected override void OnDragDrop(DragEventArgs drgevent)
        {
            if (this.CanDrag(drgevent))
            {
                Point p = new Point(drgevent.X, drgevent.Y);
                p = base.PointToClient(p);
                TreeNode nodeAt = base.GetNodeAt(p);
                ArrayList data = drgevent.Data.GetData(typeof(ArrayList)) as ArrayList;
                if (((data != null) && (data.Count > 0)) && ((nodeAt != null) && (nodeAt.Tag is KB_List)))
                {
                    try
                    {
                        KB_List tag = nodeAt.Tag as KB_List;
                        foreach (object obj2 in data)
                        {
                            if (obj2 is KB_Item)
                            {
                                tag.AppendItem(obj2 as KB_Item);
                            }
                            if ((obj2 is KB_List) && tag.AppendChild(obj2 as KB_List))
                            {
                                TreeNode nodeByKBList = this.GetNodeByKBList(obj2 as KB_List, null);
                                if ((nodeByKBList != null) && (nodeByKBList.Parent != null))
                                {
                                    nodeByKBList.Remove();
                                    nodeAt.Nodes.Add(nodeByKBList);
                                    this.RefreshNode(nodeByKBList);
                                }
                            }
                        }
                    }
                    catch (Exception exception)
                    {
                        MessageBox.Show(exception.ToString());
                    }
                    this.RefreshNode(nodeAt);
                    this.RefreshChildNode(nodeAt, true);
                    nodeAt.Expand();
                    drgevent.Effect = DragDropEffects.Move;
                    base.OnDragDrop(drgevent);
                }
            }
        }

        protected override void OnDragLeave(EventArgs e)
        {
            if (this.myLastDragNode != null)
            {
                this.RefreshNode(this.myLastDragNode);
                this.myLastDragNode = null;
            }
        }

        protected override void OnDragOver(DragEventArgs drgevent)
        {
            if (this.CanDrag(drgevent))
            {
                drgevent.Effect = DragDropEffects.Move;
            }
            else
            {
                drgevent.Effect = DragDropEffects.None;
            }
        }

        protected override void OnGiveFeedback(GiveFeedbackEventArgs gfbevent)
        {
            gfbevent.UseDefaultCursors = true;
        }

        protected virtual void OnKBItemClick(TreeNode TreeNode, KB_Item SelectedItem)
        {
            if (this.EnableClickEvent)
            {
                if (this.myBindControl != null)
                {
                    UcEditorControl myBindControl = this.myBindControl as UcEditorControl;
                    if ((myBindControl != null) && SelectedItem.isTemplate())
                    {
                        A_Action actionByName = myBindControl.GetActionByName("insertdocument");
                        if (actionByName != null)
                        {
                            actionByName.Param1 = SelectedItem.ItemValue;
                            actionByName.Execute();
                        }
                    }
                }
                if (this.KBItemClick != null)
                {
                    this.KBItemClick(TreeNode, SelectedItem);
                }
            }
        }

        protected virtual void OnKBListClick(TreeNode TreeNode, KB_List SelectedList)
        {
            if (this.EnableClickEvent)
            {
                if (this.myBindControl != null)
                {
                    ZYKBListView myBindControl = this.myBindControl as ZYKBListView;
                    if (myBindControl != null)
                    {
                        myBindControl.ShowChildKBList = SelectedList.HasChildren();
                        myBindControl.OwnerKBList = SelectedList;
                    }
                    UcEditorControl control = this.myBindControl as UcEditorControl;
                    if (control != null)
                    {
                        control.EMRDoc._InsertKB(SelectedList);
                    }
                }
                if (this.KBListClick != null)
                {
                    this.KBListClick(TreeNode, SelectedList);
                }
            }
        }

        protected override void OnMouseDown(MouseEventArgs e)
        {
            if ((e.Button == MouseButtons.Left) && (base.Nodes.Count > 0))
            {
                this.myLastMousePos = new Point(e.X, e.Y);
                this.myDragNode = base.GetNodeAt(e.X, e.Y);
                if (this.myDragNode == base.Nodes[0])
                {
                    this.myDragNode = null;
                }
                if (this.myDragNode != null)
                {
                    if (!this.myDragNode.Bounds.Contains(e.X, e.Y))
                    {
                        this.myDragNode = null;
                    }
                    else if (this.DesignKBMode)
                    {
                        this.myDragNode.BackColor = SystemColors.Highlight;
                        this.myDragNode.ForeColor = SystemColors.HighlightText;
                    }
                    else
                    {
                        bool enableClickEvent = this.EnableClickEvent;
                        this.EnableClickEvent = false;
                        base.SelectedNode = this.myDragNode;
                        this.EnableClickEvent = enableClickEvent;
                    }
                }
            }
            base.OnMouseDown(e);
        }

        protected override void OnMouseMove(MouseEventArgs e)
        {
            if ((e.Button == MouseButtons.Left) && (this.myDragNode != null))
            {
                RectangleObject obj2 = new RectangleObject();
                obj2.SetRect(this.myLastMousePos.X, this.myLastMousePos.Y, e.X, e.Y);
                if ((obj2.Width > SystemInformation.DragSize.Width) || (obj2.Height > SystemInformation.DragSize.Height))
                {
                    this.RefreshNode(this.myDragNode);
                    ArrayList data = new ArrayList();
                    data.Add(this.myDragNode.Tag);
                    DataObject obj3 = new DataObject(data);
                    base.DoDragDrop(obj3, DragDropEffects.Link | DragDropEffects.Move | DragDropEffects.Copy | DragDropEffects.Scroll);
                    return;
                }
            }
            base.OnMouseMove(e);
        }

        protected override void OnMouseUp(MouseEventArgs e)
        {
            if (this.myDragNode != null)
            {
                this.RefreshNode(this.myDragNode);
            }
            if (this.bolDesignKBMode)
            {
                if (base.LabelEdit && (e.Button == MouseButtons.Right))
                {
                    TreeNode nodeAt = base.GetNodeAt(e.X, e.Y);
                    if (nodeAt != null)
                    {
                        base.SelectedNode = nodeAt;
                    }
                }
            }
            else if (e.Button == MouseButtons.Right)
            {
                TreeNode node = base.GetNodeAt(e.X, e.Y);
                if (((node != null) && node.Bounds.Contains(e.X, e.Y)) && (node.Tag is KB_List))
                {
                    KB_List tag = (KB_List) node.Tag;
                    if (tag.HasItems())
                    {
                        base.SelectedNode = node;
                        ArrayList list2 = new ArrayList();
                        list2.Add(new MenuItem(string.Concat(new object[] { "知识点[ ", tag.Name, " ]共 ", tag.Items.Count, " 个项目" })));
                        list2.Add(new MenuItem("-"));
                        int num = 0;
                        foreach (KB_Item item in tag.Items)
                        {
                            list2.Add(new MenuItem(item.ItemText));
                            if (num++ > 30)
                            {
                                break;
                            }
                        }
                        using (ContextMenu menu = new ContextMenu((MenuItem[]) list2.ToArray(typeof(MenuItem))))
                        {
                            menu.Show(this, new Point(node.Bounds.Left, node.Bounds.Bottom));
                        }
                    }
                }
            }
        }

        public void RefreshAllNode()
        {
            base.BeginUpdate();
            this.RefreshNodes(base.Nodes[0].Nodes);
            base.EndUpdate();
        }

        public void RefreshChildNode(bool bolMoveNode)
        {
            this.RefreshChildNode(base.SelectedNode, bolMoveNode);
            this.RefreshNode(base.SelectedNode);
        }

        public void RefreshChildNode(TreeNode myRootNode, bool bolMoveNode)
        {
            if (myRootNode != null)
            {
                if (bolMoveNode)
                {
                    TreeNodeCollection nodes = myRootNode.Nodes;
                    base.BeginUpdate();
                    if (nodes.Count > 0)
                    {
                        this.RefreshNode(nodes[0]);
                    }
                    for (int i = 1; i < (nodes.Count - 1); i++)
                    {
                        TreeNode myNode = nodes[i];
                        this.RefreshNode(myNode);
                        IListIndex index = nodes[i - 1].Tag as IListIndex;
                        IListIndex index2 = myNode.Tag as IListIndex;
                        if (index2.ListIndex < index.ListIndex)
                        {
                            myRootNode.Nodes.Remove(myNode);
                            foreach (TreeNode node2 in nodes)
                            {
                                if ((node2.Tag as IListIndex).ListIndex > index2.ListIndex)
                                {
                                    nodes.Insert(nodes.IndexOf(node2), myNode);
                                    goto Label_00E4;
                                }
                            }
                        Label_00E4:;
                        }
                    }
                    KB_List tag = myRootNode.Tag as KB_List;
                    if ((tag != null) && tag.HasChildren())
                    {
                        foreach (KB_List list2 in tag.ChildNodes)
                        {
                            bool flag = false;
                            foreach (TreeNode node3 in nodes)
                            {
                                if (node3.Tag == list2)
                                {
                                    flag = true;
                                    goto Label_017F;
                                }
                            }
                        Label_017F:
                            if (!flag)
                            {
                                TreeNode node = new TreeNode();
                                nodes.Add(node);
                                node.Tag = list2;
                                this.RefreshNode(node);
                            }
                        }
                    }
                    base.EndUpdate();
                }
                else
                {
                    foreach (TreeNode node5 in myRootNode.Nodes)
                    {
                        this.RefreshNode(node5);
                    }
                }
            }
        }

        public void RefreshCurrentNode()
        {
            this.RefreshNode(base.SelectedNode);
        }

        public void RefreshNode(TreeNode myNode)
        {
            if (myNode != null)
            {
                if (myNode.Tag is KB_List)
                {
                    KB_List tag = myNode.Tag as KB_List;
                    if (myNode.Text != tag.Name)
                    {
                        myNode.Text = tag.Name;
                    }
                    myNode.ImageIndex = GetICONIndex(tag, (myNode.Nodes.Count > 0) && myNode.IsExpanded);
                }
                if (myNode.Tag is KB_Item)
                {
                    KB_Item myRecord = myNode.Tag as KB_Item;
                    if (myNode.Text != myRecord.ItemText)
                    {
                        myNode.Text = myRecord.ItemText;
                    }
                    myNode.ImageIndex = GetICONIndex(myRecord, false);
                }
                myNode.SelectedImageIndex = myNode.ImageIndex;
                myNode.BackColor = GetItemBackColor(myNode.Tag as ZYDBRecordBase);
                if (this.myKBBuffer != null)
                {
                    myNode.ForeColor = this.myKBBuffer.GetItemForeColor(myNode.Tag as KB_List);
                }
                if ((myNode.Tag is KB_Item) && (myNode.Parent != null))
                {
                    myNode.ForeColor = myNode.Parent.ForeColor;
                }
            }
        }

        public void RefreshNodeColor(TreeNode myRootNode)
        {
            if (myRootNode != null)
            {
                myRootNode.BackColor = GetItemBackColor(myRootNode.Tag as ZYDBRecordBase);
                if (this.myKBBuffer != null)
                {
                    if (myRootNode.Tag is KB_List)
                    {
                        myRootNode.ForeColor = this.myKBBuffer.GetItemForeColor(myRootNode.Tag as KB_List);
                    }
                    if (myRootNode.Tag is KB_Item)
                    {
                        myRootNode.ForeColor = myRootNode.Parent.ForeColor;
                    }
                }
                foreach (TreeNode node in myRootNode.Nodes)
                {
                    this.RefreshNodeColor(node);
                }
            }
        }

        private void RefreshNodeIcon(TreeNode myNode)
        {
            myNode.ImageIndex = GetICONIndex(myNode.Tag as KB_List, myNode.IsExpanded);
            myNode.SelectedImageIndex = myNode.ImageIndex;
        }

        private bool RefreshNodes(TreeNodeCollection nodes)
        {
            bool flag = false;
            for (int i = nodes.Count - 1; i >= 0; i--)
            {
                ZYDBRecordBase tag = nodes[i].Tag as ZYDBRecordBase;
                if (tag != null)
                {
                    if (tag.isDeleted())
                    {
                        nodes.RemoveAt(i);
                        flag = true;
                    }
                    else
                    {
                        this.RefreshNodes(nodes[i].Nodes);
                        this.RefreshNode(nodes[i]);
                    }
                }
            }
            return flag;
        }

        public void ResetContent()
        {
            base.BeginUpdate();
            base.Nodes.Clear();
            TreeNode node = new TreeNode(this.myRootKBList.Name);
            if (RunInDesigner)
            {
                object text = node.Text;
                node.Text = string.Concat(new object[] { text, "(共有 ", ZYKBBuffer.Instance.AllKBList.Count - 1, " 个项目)" });
            }
            base.Nodes.Add(node);
            node.Tag = this.myRootKBList;
            this.ResetNode(node);
            node.ImageIndex = 0;
            node.Expand();
            base.EndUpdate();
            this.Refresh();
        }

        public void ResetNode(TreeNode RootNode)
        {
            KB_List tag = RootNode.Tag as KB_List;
            if (tag != null)
            {
                TreeNode node = null;
                if (tag.ChildNodes != null)
                {
                    foreach (KB_List list2 in tag.ChildNodes)
                    {
                        if (this.bolDesignKBMode || list2.Visible)
                        {
                            node = new TreeNode(list2.Name);
                            RootNode.Nodes.Add(node);
                            node.Tag = list2;
                            this.RefreshNode(node);
                            this.ResetNode(node);
                        }
                    }
                }
                if (this.ShowKBItem && (tag.Items != null))
                {
                    foreach (KB_Item item in tag.Items)
                    {
                        if (((!this.ShowNormalKBItem || !item.isNormalItem()) && (!this.ShowSystemKBItem || !item.isSystemItem())) && (!this.ShowTemplateKBItem || !item.isTemplate()))
                        {
                            continue;
                        }
                        node = new TreeNode(item.ItemText);
                        node.Tag = item;
                        this.RefreshNode(node);
                        RootNode.Nodes.Add(node);
                    }
                }
            }
        }

        public TreeNode SearchNode(TreeNode StartNode, string strFind, bool MatchAll)
        {
            if (StartNode == null)
            {
                StartNode = base.SelectedNode;
            }
            if (StartNode == null)
            {
                StartNode = base.Nodes[0];
            }
            if (StringCommon.isBlankString(strFind))
            {
                return null;
            }
            this.myStartNode = StartNode;
            this.strSearchText = strFind;
            this.bolMatchAll = MatchAll;
            this.bolStartMatch = false;
            return this.InnerSearchNode(base.Nodes);
        }

        public void SetDeleteFlag(TreeNode RootNode)
        {
            if (RootNode.Tag is KB_Item)
            {
                (RootNode.Tag as KB_Item).DataState = DataRowState.Deleted;
            }
            else if (RootNode.Tag is KB_List)
            {
                (RootNode.Tag as KB_List).DataState = DataRowState.Deleted;
            }
            this.RefreshNode(RootNode);
            foreach (TreeNode node in RootNode.Nodes)
            {
                this.SetDeleteFlag(node);
            }
        }

        public void SetSectionFlag(TreeNode RootNode, string strSection)
        {
            if (RootNode.Tag is KB_List)
            {
                (RootNode.Tag as KB_List).OwnerSection = strSection;
            }
            this.RefreshNode(RootNode);
            foreach (TreeNode node in RootNode.Nodes)
            {
                this.SetSectionFlag(node, strSection);
            }
        }

        public void SetTreeNodeICON(TreeNode myNode)
        {
            if ((myNode != null) && (myNode != base.Nodes[0]))
            {
                int iCONIndex = GetICONIndex(myNode.Tag as ZYDBRecordBase, myNode.IsExpanded);
                myNode.ImageIndex = iCONIndex;
                myNode.SelectedImageIndex = iCONIndex;
                myNode.BackColor = GetItemBackColor(myNode.Tag as ZYDBRecordBase);
                KB_List tag = myNode.Tag as KB_List;
                if (this.myKBBuffer != null)
                {
                    myNode.ForeColor = this.myKBBuffer.GetItemForeColor(myNode.Tag as KB_List);
                }
            }
        }

        public Control BindControl
        {
            get
            {
                return this.myBindControl;
            }
            set
            {
                this.myBindControl = value;
            }
        }

        public bool DesignKBMode
        {
            get
            {
                return this.bolDesignKBMode;
            }
            set
            {
                this.bolDesignKBMode = value;
                RunInDesigner = value;
            }
        }

        public bool DoubleClickMode
        {
            get
            {
                return this.bolDoubleClickMode;
            }
            set
            {
                this.bolDoubleClickMode = value;
            }
        }

        public ZYKBBuffer KBBuffer
        {
            get
            {
                return this.myKBBuffer;
            }
            set
            {
                this.myKBBuffer = value;
            }
        }

        public KB_List RootKBList
        {
            get
            {
                return this.myRootKBList;
            }
            set
            {
                this.myRootKBList = value;
            }
        }

        public KB_List SelectedKBList
        {
            get
            {
                if (base.SelectedNode != null)
                {
                    return (base.SelectedNode.Tag as KB_List);
                }
                return null;
            }
            set
            {
                if ((value != null) && (value.SEQ != null))
                {
                    TreeNode nodeByKBList = this.GetNodeByKBList(value, null);
                    if (nodeByKBList != null)
                    {
                        base.SelectedNode = nodeByKBList;
                    }
                }
            }
        }

        public bool ShowKBItem
        {
            get
            {
                return this.bolShowKBItem;
            }
            set
            {
                this.bolShowKBItem = value;
            }
        }

        public bool ShowNormalKBItem
        {
            get
            {
                return (this.bolShowKBItem ? this.bolShowNormalKBItem : false);
            }
            set
            {
                this.bolShowNormalKBItem = value;
            }
        }

        public bool ShowSystemKBItem
        {
            get
            {
                return (this.bolShowKBItem ? this.bolShowSystemKBItem : false);
            }
            set
            {
                this.bolShowSystemKBItem = value;
            }
        }

        public bool ShowTemplateKBItem
        {
            get
            {
                return (this.bolShowKBItem ? this.bolShowTemplateKBItem : false);
            }
            set
            {
                this.bolShowTemplateKBItem = value;
            }
        }
    }
}

